#include <stdio.h>
#include <algorithm>
using namespace std;

#define TRACE(x...) x
#define PRINT(x...) TRACE(printf(x)) 

#define rep(i,n) for (int i=0; i<n; i++)

#define INF 0x3f3f3f3f3f3f3f3fLL

long long two[60];
long long five[25];
long long three[36];
long long nums[100010];
int cont;
long long tmp;

int main() {
	two[0]=1;
	three[0]=1;
	five[0]=1;

	for (int i=1; i<60; i++) { 
		two[i]=two[i-1]*2;
		if (two[i]>INF) two[i]=INF;
	}
	for (int i=1; i<36; i++) {
		three[i]=three[i-1]*3;
		if (three[i]>INF) three[i]=INF;
	}
	for (int i=1; i<25; i++) {
		five[i]=five[i-1]*5;
		if (five[i]>INF) five[i]=INF;
	}

	cont=0;

	for (int i=0; i<25; i++) {
		for (int j=0; j<36; j++) {
			for (int k=0; k<60; k++) {
				tmp = two[k];
				tmp *=three[j];
				if (tmp<0) break;

				tmp*=five[i];
				if (tmp<0) break;

				nums[cont++]=tmp;
			}
		}
	}

	sort(nums,nums+cont);
	printf("The 1500'th ugly number is %lld.\n", nums[1499]);

	return 0;
}
